<template>
    <div class="app-container">
      <el-form :inline="true" :model="params" ref="queryForm">
        <el-form-item label="登记姓名" prop="enrollName">
            <el-input v-model="params.enrollName" placeholder="请输入登记姓名"
            clearable
            size="small"
            style="width: 180px"
             @keyup.enter.native="handleQuery"></el-input>
        </el-form-item>
        <el-form-item label="专业名称" prop="majorName">
          <el-input v-model="params.majorName" placeholder="请输入专业名称"
          clearable
          size="small"
          style="width: 180px"
          @keyup.enter.native="handleQuery"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleQuery">查询</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>

        </el-form-item>
      </el-form>


      <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <download-excel
            class="export-excel-wrapper"
            :data="excelList"
            :fields="json_fields"
            :header="excelTitle"
            name="报名信息.xls"

            >
        <!-- 上面可以自定义自己的样式，还可以引用其他组件button -->
        <el-button type="warning" icon="el-icon-download" size="mini" >报名信息导出</el-button>
        </download-excel>
      </el-col>


    </el-row>

      <el-table :data="enrollList" >
        <el-table-column label="序号" type="index"/>
        <el-table-column label="登记姓名" align="center" prop="enrollName" />
        <el-table-column label="登记号码" align="center" prop="enrollPhone" :show-overflow-tooltip="true"/>
        <el-table-column label="专业名称" align="center" prop="majorName" />
        <el-table-column label="毕业类型" align="center" prop="graduationType" >
            <template slot-scope="scope">
            <label v-if="scope.row.graduationType==1">初中</label>
            <label v-if="scope.row.graduationType==2">高中</label>
          </template>
        </el-table-column>
        <el-table-column label="创建人" align="center" prop="createBy" />
        <el-table-column label="生成时间" align="center" width="160">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="修改人" align="center" prop="modifyBy" />
        <el-table-column label="修改时间" align="center" width="160">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.modifyTime) }}</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="params.pageNum" :limit.sync="params.pageSize"
        @pagination="getList" />
    </div>
  </template>

<script>
  import { getList } from "@/api/workmgr/recruitEnroll.js";
  export default {
    name: "recruitEnroll",
    data() {
      return {

        //列表显示
        params: { // 查询条件的值
          pageNum: 1,
          pageSize: 10,
          enrollName: undefined,
          majorName: undefined
        },
        enrollList: [],
        excelList: [],
        exportDataList:[],
      excelTitle:'报名信息',
      total: 0,
      json_fields:{
        "登记姓名":"enrollName",
        "登记号码":"enrollPhone",
        "专业名称":"majorName",
        "毕业类型":"graduationType",
        "创建人":"createBy",
        "创建时间":"createTime",
      }
      };
    },
    // 生命周期 - 创建完成（可以访问当前this实例）
    created() {
      this.getList();
      this.getExportData();
    },
    methods: {
      /** 工作考评列表 */
      getList() {
        getList(this.params).then(res => {
          this.enrollList = res.data.list;
          this.total = res.data.total;
        })
      },


      /** 搜索按钮操作 */
      handleQuery() {
        this.params.pageNum = 1;
        this.getList();
      },
        /** 重置按钮操作 */
    resetQuery() {
    this.params.enrollName = null;
    this.params.majorName = null;
      this.resetForm("queryForm");
      this.handleQuery();
    },
    getExportData() {
      getList({pageNum:1,pageSize:10000}).then(response => {
      this.excelList = [],
      this.exportDataList =  JSON.parse(JSON.stringify(response.data.list));
      for(let i=0;i<this.exportDataList.length;i++){
        this.excelList[i]=this.exportDataList[i]

        this.excelList[i].createTime = this.parseTime(this.exportDataList[i].createTime)
      }
        }
      );
    }
    }
}
  </script>
